package com.atguigu.mr.index;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @description: 多个map传递任务
 * @time: 2020-01-06 20:51
 * @author: baojinlong
 **/
public class TwoIndexMapper extends Mapper<LongWritable, Text, Text, Text> {
    private Text nowKey = new Text();
    private Text nowValue = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        // 拿到一行数据atguigu--a.txt 3
        String line = value.toString();
        // 切割
        String[] fields = line.split("--");
        nowKey.set(fields[0]);
        nowValue.set(fields[1]);
        context.write(nowKey, nowValue);
    }
}
